<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>RG PORTAL</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="stylesheet" type="text/css"
	href="<c:url value='/resources/css/bootstrap.css'/>" />
<link rel="stylesheet" type="text/css"
	href="<c:url value='/resources/css/bootstrap-responsive.css'/>" />
<script src="<c:url value='/resources/js/jquery.js'/>"></script>
<script src="<c:url value='/resources/js/bootstrap.js'/>"></script>
<style type="text/css">
body {
	padding-top: 60px;
	padding-bottom: 40px;
}
</style>


<script type="text/javascript">
function atualizarHiddenUsuarioASerExcluido(valor) {
	$('#usuarioASerExcluido').val(valor);
}

function excluirUsuario() {	
	$('#formularioExclusao').attr('action', '/rgportal/admin/usuarios/excluir/'+$('#usuarioASerExcluido').val());
	$('#linkExclusao').click();
}

</script>


</head>

<body>
	<input type="hidden" id="usuarioASerExcluido">
	<%@ include file="/WEB-INF/views/admin/menu.jsp"%>

	<div class="container">

		<div class="hero-unit">
			<center>
				<h3>Lista de Usuarios</h3>
			</center>
			<hr style="border-color:#000;">
			<br>
			
			<table class="table">
			<thead>
				<tr>
					<th>Nome</th>
					<th>Login</th>
					<th>Permissao</th>
					<th></th>
					<th></th>
				</tr>
			</thead>
			<tbody>
			<c:forEach items="${usuarios}" var="usuario">
				<tr>
					<td>${usuario.nome}</td>
					<td>${usuario.login}</td>
					<td>${usuario.permissoes[0].grupo}</td>				
            		<td><a title="Editar" href="/rgportal/admin/usuarios/editar/${usuario.id}" class="btn btn-small btn-info" type="submit" ><i class="icon-edit"></i></a></td> 
            		<td><a title="Excluir" href="#modalExclusaoUsuario" onclick="atualizarHiddenUsuarioASerExcluido(${usuario.id});" class="btn btn-small btn-danger" role="button" class="btn" data-toggle="modal"><i class="icon-trash"></i></a></td>  
				</tr>			
			</c:forEach>
			</tbody>
		</table>
				
		</div>
		
		<div id="modalExclusaoUsuario" class="modal hide fade" >
		  <div class="modal-header">
		    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
		    <h3>Atenção!</h3>
		  </div>
		  <div class="modal-body">
		    <p>Tem certeza que deseja excluir este usuário?</p>
		  </div>
		  <div class="modal-footer">
		 	<button onclick="excluirUsuario();" class="btn btn-danger">Excluir</button>
		    <button class="btn" data-dismiss="modal" aria-hidden="true">Cancelar</button>		    		    
		  </div>
		  	<form id="formularioExclusao">
            	<button href="" id="linkExclusao" type="submit" class="hide"></a>
            </form> 
		 
		</div>
		
		

		<%@ include file="/WEB-INF/views/admin/rodape.jsp"%>

	</div>
	<!-- /container -->

	<!-- Le javascript
    ================================================== -->
	<!-- Placed at the end of the document so the pages load faster -->
</body>
</html>
